package com.qumitech.visualnovel.controller.rest;

import com.qumitech.visualnovel.model.common.BaseRsp;
import com.qumitech.visualnovel.model.common.ResultEnum;
import com.qumitech.visualnovel.service.reviewdashboard.ReviewDashBoardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/review_dashboard")
public class ReviewDashBoardController {

    @Autowired
    private ReviewDashBoardService reviewDashBoardService ;

    @GetMapping("")
    public BaseRsp getReviewDashBoard(@RequestParam("start_time") String startTime,
                                      @RequestParam("end_time") String endTime)
    {
        return new BaseRsp(ResultEnum.SUCCESS, reviewDashBoardService.getReviewDashboardStatistic(startTime,endTime));
    }

    @GetMapping(value = "/okr/conf/list")
    public BaseRsp getOKRConfList() {
        return reviewDashBoardService.getOKRConfList();
    }

    @GetMapping(value = "/okr/data/list")
    public BaseRsp getOKRDataList(
        @RequestParam(value = "okrType", required = true) String okrType,
        @RequestParam(value = "startTime", required = false) String startTime,
        @RequestParam(value = "endTime", required = false) String endTime,
        @RequestParam(value = "offset", required = true) String offset,
        @RequestParam(value = "limit", required = true) String limit) {
        return reviewDashBoardService.getOKRDataList(okrType, startTime, endTime, offset, limit);
    }

    @GetMapping(value = "/okr/data/line")
    public BaseRsp getOKRDataLine(
        @RequestParam(value = "okrType", required = true) String okrType,
        @RequestParam(value = "startTime", required = false) String startTime,
        @RequestParam(value = "endTime", required = false) String endTime,
        @RequestParam(value = "offset", required = true) String offset,
        @RequestParam(value = "limit", required = true) String limit) {
        return reviewDashBoardService.getOKRDataLine(okrType, startTime, endTime, offset, limit);
    }

    @GetMapping(value = "/user/registerList")
    public BaseRsp getUserRegisterList(
        @RequestParam(value = "startTime", required = false) String startTime,
        @RequestParam(value = "endTime", required = false) String endTime,
        @RequestParam(value = "offset", required = false, defaultValue = "0") Integer offset,
        @RequestParam(value = "limit", required = false, defaultValue = "20") Integer limit) {
        return reviewDashBoardService.getUserRegisterList(startTime, endTime, offset, limit);
    }

    @GetMapping(value = "/user/registerStatistic")
    public BaseRsp getUserRegisterStatistic(
        @RequestParam(value = "category", required = true) String category,
        @RequestParam(value = "startTime", required = false) String startTime,
        @RequestParam(value = "endTime", required = false) String endTime) {
        return reviewDashBoardService.getUserRegisterStatistic(category, startTime, endTime);
    }

    @GetMapping(value = "/user/loginList")
    public BaseRsp getUserLoginList(
        @RequestParam(value = "startTime", required = false) String startTime,
        @RequestParam(value = "endTime", required = false) String endTime,
        @RequestParam(value = "offset", required = false, defaultValue = "0") Integer offset,
        @RequestParam(value = "limit", required = false, defaultValue = "20") Integer limit) {
        return reviewDashBoardService.getUserLoginList(startTime, endTime, offset, limit);
    }

    @GetMapping(value = "/user/loginStatistic")
    public BaseRsp getUserLoginStatistic(
        @RequestParam(value = "category", required = true) String category,
        @RequestParam(value = "startTime", required = false) String startTime,
        @RequestParam(value = "endTime", required = false) String endTime) {
        return reviewDashBoardService.getUserLoginStatistic(category, startTime, endTime);
    }
}
